﻿#include "pch.h"

CAmtInfWrapper::CAmtInfWrapper()
{
    memset((void *)this, 0, sizeof(CAmtInfWrapper));
}

void CAmtInfWrapper::printSelf(char *captionUpper, int32_t)
{
    char caption[1024];
    sprintf(caption, "%s:%s", captionUpper, "CAmtInfWrapper");
    print4x(this, sizeof(CAmtInfWrapper), caption);
    if (this->head)
    {
        sprintf(caption, "%s:%s", captionUpper, "CAmtInfWrapper.head");
        print4x(this->head, this->len * this->size, caption);
    }
}

// sub_10022EDF
CAmtInfWrapper *CAmtInfWrapper::init(TAMTINF *refInf)
{
    this->init(refInf->head, (int32_t)refInf->len, (int32_t *)refInf->num);
    this->repIndexes = new int32_t[this->len];
    memset((void *)this->repIndexes, 0, 4 * this->len);
    return this;
}

// sub_10025140
CAmtInfWrapper *CAmtInfWrapper::init(TSTDAMTListItem *head, int32_t len, int32_t *num)
{
    this->head = (LPVOID)head;
    this->size = 64;
    this->len = len;
    this->tail = 0;
    this->needFreeHead = false;
    this->num = num;
    return this;
}

// sub_10022F73
double CAmtInfWrapper::getAmtMValue(int32_t idx, int32_t method)
{
    return calcAmtMValue((TSTDAMTListItem *)((BYTE *)this->head + sizeof(TSTDAMTListItem) * idx), method);
}

// sub_10022F9A
double CAmtInfWrapper::getAmtM2Value(int32_t idx)
{
    return calcAmtMValue((TSTDAMTListItem *)((BYTE *)this->head + sizeof(TSTDAMTListItem) * idx), 2);
}

// sub_10024ED0
void *CAmtInfWrapper::clear()
{
    return memset(this->repIndexes, 0, 4 * this->len);
}

// sub_1001D4F0
CBaseWrapper *CAmtInfWrapper::close(char flag)
{
    this->close();
    if (flag & 1)
    {
        delete this;
        return NULL;
    }
    return this;
};

// sub_1001D520
CBaseWrapper *CAmtInfWrapper::close()
{
    delete[] this->repIndexes;
    return this->close_();
};

// sub_1001ADD0
int32_t CAmtInfWrapper::getRepIndex(int32_t idx)
{
    return this->repIndexes[idx];
}
